package com.situ.day4;

import java.util.Scanner;

import org.junit.Test;

public class SwitchDemo {
	
	@Test
	public void test1() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("Please input a year:");
		int year = scanner.nextInt();
		System.out.println("Please input a month:");
		int month = scanner.nextInt();
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println(year + "年" + month + "月有31天");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println(year + "年" + month + "月有30天");
			break;
		case 2:
			if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
				System.out.println(year + "年" + month + "月有29天");
			} else {
				System.out.println(year + "年" + month + "月有28天");
			}
			break;
		default:
			System.out.println("输入月份有误!");
		}
	}
	
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("Please input a grade:");
		double grade = scanner.nextDouble();
		if (grade < 0 || grade > 100) {
			System.out.println("输入成绩无效！");
			return;
		}
		switch ((int) (grade / 10)) {
		case 10:
		case 9:
			System.out.println("成绩优秀！");
			break;
		case 8:
			System.out.println("成绩一般！");
			break;
		case 7:
			System.out.println("成绩良好！");
			break;
		case 6:
			System.out.println("成绩及格！");
			break;                  
		default:
			System.out.println("不及格！");
			break;
		}
	}
}
